package largestTriangleArea;

public class Solution {
    public double largestTriangleArea(int[][] points) {
        double max=0;
//        for (int[]point1: points) {
//            for (int[]point2: points) {
//                for (int[]point3: points) {
//                    int x1=point1[0];
//                    int y1=point1[1];
//                    int x2=point2[0];
//                    int y2=point2[1];
//                    int x3=point3[0];
//                    int y3=point3[1];
//                    double s=(x1*y2-x1*y3+x2*y3-x2*y1+x3*y1-x2*y2);
//                    if(max<s){
//                        max=s;
//                    }
//                }
//            }
//        }
        for (int i = 0; i < points.length-2; i++) {
            for (int j = i+1; j < points.length-1; j++) {
                for (int k = j+1; k < points.length; k++) {
                    int x1=points[i][0];
                    int y1=points[i][1];

                    int x2=points[j][0];
                    int y2=points[j][1];

                    int x3=points[k][0];
                    int y3=points[k][1];

                    double s= Math.abs(x1*y2+x2*y3+x3*y1-x1*y3-x2*y1-x3*y2);
                    if(max<s){
                        max=s;
                    }
                }
            }
        }
        return max/2;
    }
}
//x1y2＋x2y3＋x3y1－x1y3－x2y1－x3y2
